home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / turlvi16.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  3.0 KB  |  98 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TURLView
  4. //    Include File:    turlview.h
  5. //    Purpose:    Provide the view of a URL
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-27-93    created
  9. //        02-02-94    Began a major revision to fully handle a
  10. //                multiple document interface with WWW, take
  11. //                over the formatting and drawing of the
  12. //                old gridtext functions of HText, and optimize
  13. //                memory usage, selecting anchors, the usage of
  14. //                HText's new image file.  See gridtext.
  15. //        02-09-94    Split all members into seperate files.
  16. #include"turlview.h"
  17.  
  18. Boolean TURLView::AnchorSelectXYView(signed short int ssi_x, signed short int
  19.     ssi_y)    {
  20. //    Purpose:    Attempt to select the anchor in view corresponding
  21. //            to the ssi_x and ssi_y coordinates.
  22. //    Arguments:    ssi_x    The view horizontal coordinate.
  23. //            ssi_y    The view vertical coordinate.
  24. //    Return Value:    Boolean    True    There was a valid anchor under the
  25. //                    specified coordinates.
  26. //                    The selected anchor has been updated.
  27. //                False    Attempt to make an invalid selection.
  28. //    Remarks/Portability/Dependencies/Restrictions:
  29. //        For use with mouse.
  30. //        Extra lines beneath the end of HText in the view will cause
  31. //        problems.  Watch out.
  32. //    Revision History:
  33. //        01-30-94    created.
  34.  
  35.     //    First make sure anchors exist in the document.
  36.     if(TNSCp_anchors->getCount() == 0)    {
  37.         return(False);
  38.     }
  39.  
  40.     //    If by some freak of nature, that the y coordinate will be
  41.     //    beyond the document.  Don't let this happen.
  42.     if(delta.y + ssi_y >= limit.y)    {
  43.         return(False);
  44.     }
  45.  
  46.     //    Figure out the line which the view wishes to select.
  47.     ssi_y += delta.y;
  48.     ssi_x += delta.x;
  49.  
  50.     //    Convert to a rendered stream offset.
  51.     //    Beginning of line.
  52.     auto signed long int sli_offset = (signed long int)(TNSCp_lines->
  53.         at(ssi_y));
  54.     //    Seek and obtain line information.
  55.     auto Line L_mouse;
  56.     fsp_temp->seekg(sli_offset);
  57.     fsp_temp->read((char *)(&L_mouse), sizeof(Line));
  58.     if(fsp_temp->gcount() != sizeof(Line))    {
  59.         doslynxmessage("Error in reading rendered image file.");
  60.         return(False);
  61.     }
  62.     //    Move past the line information.
  63.     sli_offset += sizeof(Line);
  64.     //    Make sure X coordinates do not go past the line data.
  65.     if(ssi_x - L_mouse.ssi_indent > L_mouse.ssi_length)    {
  66.         return(False);
  67.     }
  68.     //    Make sure X coordinates do not go before the line data.
  69.     else if(ssi_x - L_mouse.ssi_indent < 0)    {
  70.         return(False);
  71.     }
  72.  
  73.     //    Adjust for X coordinates.
  74.     //    Should now be a correct offset.
  75.     sli_offset += ssi_x - L_mouse.ssi_indent;
  76.  
  77.     //    Go through each anchor with a child.
  78.     auto TextAttribute *TAp_mouse;
  79.     for(signed short int ssi_find = 0; ssi_find < TNSCp_anchors->
  80.         getCount(); ssi_find++)    {
  81.  
  82.         //    Extract an anchor.
  83.         TAp_mouse = (TextAttribute *)(TNSCp_anchors->at(ssi_find));
  84.  
  85.         //    Continue if not in range.
  86.         if(TAp_mouse->inRange(sli_offset) == 0)    {
  87.             continue;
  88.         }
  89.  
  90.         //    Inside and valid, select it.
  91.         TAp_selected = TAp_mouse;
  92.         return(True);
  93.     }
  94.  
  95.     //    Never found.
  96.     return(False);
  97. }
  98.